using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SSOTasks = BizTalk.BuildGenerator.Tasks.SSO;
using System.Diagnostics;
using System.IO;
using BizTalk.BuildGenerator.Tasks.SSO;

namespace BizTalk.BuildGenerator.Tasks.Tests.BRE
{
    /// <summary>
    /// Summary description for SSOTests
    /// </summary>
    [TestClass]
    public class BRETests : MSBuildTest
    {
        /// <summary>
        /// Ctor
        /// </summary>
        public BRETests()
        {

        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// Pretest setup
        /// </summary>
        [TestInitialize]
        public void Setup()
        {
            base.GetFileAndWriteToPath("BizTalk.BuildGenerator.Tasks.Tests.BRE.BRETestBuildScript.msbuild", "BRETestBuildScript.msbuild");
            base.GetFileAndWriteToPath("BizTalk.BuildGenerator.Tasks.Tests.BRE.TestPolicy.xml", "TestPolicy.xml");
            base.GetFileAndWriteToPath("BizTalk.BuildGenerator.Tasks.Tests.BRE.TestVocabulary.xml", "TestVocabulary.xml");            
        }
        /// <summary>
        /// Cleans after test
        /// </summary>
        [TestCleanup]
        public void CleanUp()
        {
            File.Delete("BRETestBuildScript.msbuild");
            File.Delete("TestVocabulary.xml");
            File.Delete("TestPolicy.xml");  
        }
        /// <summary>
        /// Tests the SSO tasks
        /// </summary>
        [TestMethod]
        public void ExecuteBREMsBuildTest()
        {
            string arguments = "BRETestBuildScript.msbuild /t:Build";
            int result = RunMSBuild(arguments);
            Assert.IsTrue(result == 0, "The MSBuild Task failed.");
            
        }
    }
}
